# 1、转换为整数int
# str ---> int
s = '2024'
n = int(s)
print(type(s), type(n))
# float  ----> int
s1 = 2.25
print(int(s1)) # 2
# bool --------> int
s2,s3 = True,False
print(int(s2),int(s3)) # 1 0


# 2、转换为浮点数float
# float ------》 float
s = '234.5' # 有没有小数点都可以
print(float(s))
# int ------> float
n = 2024
print(float(n))  # 2024.0
# bool ------->float
print(float(True),float(False))  # 1.0 0.0


# 3、转换为布尔bool
# str --> bool
s = 'sss445'
print(bool(s))  #True
s1 = ''
print(bool(s1)) # False
print(bool('0')) # True
print(bool(0)) # False
print(bool('  ')) # True

# int --> bool
print(bool(1))  # True
print(bool(0))  # False

# float --> bool
print(bool(0.0))  # False
print(bool(0.1))  # True

# 4、转换为字符串str
# int --> str
print(type(str(1)))
# float --> str
print(type(str(1.25)))
# bool --> str
print(str(True))
print(type(str(True)))


print(int('10',2))  # 数值为 2进制
print(int('1a',16))  # 数值为 16进制
